﻿using System;
    class AstrologicalDigits
    {
        static void Main()
        {
            int value = 0;
            string ch;
                ch = Console.ReadLine();
                for (int counter=0;counter<ch.Length;counter++)
                {
                    if ((ch[counter] == '-') || (ch[counter] == '.'))
                        goto skip;
                    value += (int)ch[counter]-'0';
                    if(value>9)
                        value-=9;
                skip:
                    {
                    }
                }
            Console.WriteLine(value);
        }
    }

